<%-- 
    Document   : list
    Created on : Dec 26, 2009, 1:39:23 PM
    Author     : Administrator
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib  prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<script type="text/javascript">
    function confirmDelete(id){
        var confirmed = confirm("Do you want to delete this test?");
        if (confirmed)document.getElementsByName("idToDelete").item(0).value=id;
        return confirmed;
    }

</script>
<form method="post">
    <input type="hidden" name="idToDelete"/>
    <table border="1">
        <tr><th colspan="5">List of test</th></tr>
        <tr><th>No.</th><th>Name</th><th>Number of students</th><th></th><th></th></tr>
        <c:forEach var="session" items="${sessions}" varStatus="counter">
            <tr>
                <td>${counter.count}</td>
                <td><a href="<%=request.getContextPath()%>/test/viewSession?id=${session.autoId}">${session.name}</a></td>
                <td>${session.numberOfStudents}</td>
                <td><a href="<%=request.getContextPath()%>/test/editSession?id=${session.autoId}">Assign proctors</a></td>
                <td><input type="submit" name="delete" value="Delete" onclick="return confirmDelete(${session.autoId})"/></td>
            </tr>
        </c:forEach>
    </table>
</form>
<div>
    <a href="<%=request.getContextPath()%>/test/generateSession">Generate new test session</a>
</div>
